jQuery.g.channel = function (options) {
    this.settings = jQuery.extend({
		keepAliveLink: '/alive',
		tokenSelector: '#token',
		onmessage: function (m) {
		},
		onerror: function (e) {
		},
		onopen: function () { },
		onclose: function () { }
	}, options);

	this.init();
};
jQuery.g.channel.prototype.settings = null;
jQuery.g.channel.prototype.init = function (options) {
	var s = this.settings;

	var keepAlive = function () {
		jQuery.get(s.keepAliveLink, function () { });
	};
	setInterval(keepAlive, 60000);

	var channel = new goog.appengine.Channel(jQuery(s.tokenSelector).val());
	var socket = channel.open({
		onopen: s.onopen,
		onmessage: s.onmessage,
		onerror: s.onerror,
		onclose: s.onclose
	});
};
